package com.laoye.big_event.Service.Impl;

import com.laoye.big_event.Mapper.CategoryMapper;
import com.laoye.big_event.Pojo.Category;
import com.laoye.big_event.Service.CategoryService;
import com.laoye.big_event.Utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Map;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public void addCategory(Category category) {
        Map<String,Object> map= ThreadLocalUtil.get();
        category.setCreateUser((Integer) map.get("id"));
        categoryMapper.addCategory(category);
    }

    @Override
    public ArrayList<Category> selectBycreateUser() {
        Map<String,Object> map=ThreadLocalUtil.get();
        int createUser = (int) map.get("id");
        return categoryMapper.selectBycreateUser(createUser);

    }

    @Override
    public Category selectById(int id) {
        return categoryMapper.selectById(id);
    }

    @Override
    public void updateCategory(Category category) {
        categoryMapper.updateCategory(category);
    }

    @Override
    public void deleteCategory(int id) {
        categoryMapper.deleteCategory(id);
    }
}
